package com.zw.mes.module.system.controller;

import com.zw.mes.base.BaseController;
import com.zw.mes.common.JsonResult;
import com.zw.mes.module.assemble.service.DispatchService;
import com.zw.mes.module.shipments.service.InstDispatchingCreateService;
import com.zw.mes.module.shipments.service.InstShipmentsPlanEditService;
import com.zw.mes.module.shipments.service.InstShipmentsService;
import com.zw.mes.module.system.service.UserService;
import com.zw.mes.module.tecard.service.TecardService;
import com.zw.mes.module.tecdrawsign.service.DrawCJSignService;
import com.zw.mes.module.tecdrawsign.service.DrawSignService;
import com.zw.mes.module.tecdrawsign.service.PaintingService;
import com.zw.mes.module.technology.service.PurchasedService;
import com.zw.mes.module.tecmake.service.MakeService;
import com.zw.mes.module.transpositionManager.service.TranspositionCutService;
import org.apache.shiro.authz.annotation.RequiresAuthentication;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.ui.Model;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.ResponseBody;

/**
 * @Description:
 *
 * @Author: China.sgl
 * @Date: 2020/7/30 9:42
 */
@Controller
@SuppressWarnings("all")
public class IndexController extends BaseController {

    @Autowired
    private UserService userService;
    @Autowired
    private PurchasedService purchasedService;
    @Autowired
    private MakeService makeService;
    @Autowired
    private PaintingService paintingService;
    @Autowired
    private DrawSignService drawSignService;
    @Autowired
    private DrawCJSignService drawCJSignService;
    @Autowired
    private TecardService tecardService;
    @Autowired
    private TranspositionCutService service;
    @Autowired
    private DispatchService dispatchService;
    @Autowired
    private InstShipmentsPlanEditService instShipmentsPlanEditService;
    @Autowired
    private InstShipmentsService instShipmentsService;
    @Autowired
    private InstDispatchingCreateService instDispatchingCreateService;

    @GetMapping("/index")
    public String index(Model model) {
        model.addAttribute("countPurch", purchasedService.selectReportCount());
        model.addAttribute("countTecmake", makeService.selectTecmakeCount());
        model.addAttribute("countPainting", paintingService.selectPaintingCount());
        model.addAttribute("countTecdrawsign", drawSignService.selectTecdrawsignCount());
        model.addAttribute("countChangSign", drawSignService.selectChangSignCount());
        model.addAttribute("countTecdrawcjsign", drawCJSignService.selectTecdrawcjsignCount());
        model.addAttribute("countchangSignChange", drawCJSignService.selectchangSignChangeCount());
        model.addAttribute("countTecard", tecardService.selectTecardCount());
        model.addAttribute("countCutMaintain", service.selectCutMaintainCount());
        model.addAttribute("countDispatch", dispatchService.selectDispatchCount());
        model.addAttribute("countShipmentsEdit", instShipmentsPlanEditService.selectShipmentsEditCount());
        model.addAttribute("countShipmentsComit", instShipmentsService.selectShipmentsComitCount());
        model.addAttribute("countDispatching", instDispatchingCreateService.selectDispatchingCount());
        model.addAttribute("countDispatchingExamine", instDispatchingCreateService.selectDispatchingExamineCount());
        return "index";
    }

    /**
     * 修改密码
     *
     * @param pwd 新密码
     * @return json
     */
    @ResponseBody
    @PostMapping("/update/user/pwd")
    @RequiresAuthentication
    public JsonResult updatePwd(String pwd) {
        return isNotNull(userService.updateUserPassword(pwd));
    }

}
